package cd.safe.school.adapter;

import java.util.List;

import cd.safe.school.R;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.BaseAdapter;
import android.widget.FrameLayout.LayoutParams;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;

public class GalleryAdapter2 extends BaseAdapter {
	private Context context;
	private List<Bitmap> lists;

	public GalleryAdapter2(Context context, List<Bitmap> lists) {
		super();
		this.context = context;
		this.lists = lists;
	}

	public int getCount() {

		return Integer.MAX_VALUE;
	}

	public Object getItem(int position) {

		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		final ImageView imageView = new ImageView(context);

		Bitmap bit = lists.get(position % lists.size());

		imageView.setImageBitmap(bit);

		imageView.setLayoutParams(new Gallery.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
		imageView.setScaleType(ScaleType.CENTER);
		// 添加事件gallery就不能滑动
		// imageView.setOnClickListener(new OnClickListener() {
		//
		// @Override
		// public void onClick(View v) {
		//
		// imageView.startAnimation(AnimationUtils.loadAnimation(context,
		// R.anim.transformer));
		//
		// }
		// });

		return imageView;
	}

}
